﻿@model ProductModel

@using SmartStore.Core.Domain.Catalog;

<script>
	$(function () {
		$("#@Html.FieldIdFor(model => model.ProductTypeId)").change(toggleProductType);
		toggleProductType();

		// reset required-productids
		$("#reset-required-productids").on("click", function (e) {
			e.preventDefault();
			$("#@Html.FieldIdFor(model => model.RequiredProductIds)").val("");
		});
	});

    function toggleProductType() {
        var selectedProductTypeId = $("#@Html.FieldIdFor(model => model.ProductTypeId)").val();
        if (selectedProductTypeId == '@((int)ProductType.SimpleProduct)') {
            $('#group-required-other-products').show();
            $('#group-giftcard').show();
            $('#group-downloads').show();
            $('#group-recurring').show();
            $('#group-shipping').show();
            $('#group-tax').show();
            $('#group-inventory').show();
            $('a[href="#tab-inventory"]').parent().removeClass("hide"); // specified in _CreateOrUpdate.cshtml
        }
        else if (selectedProductTypeId == '@((int)ProductType.GroupedProduct)') {
            $('#group-required-other-products').hide();
            $('#group-giftcard').hide();
            $('#group-downloads').hide();
            $('#group-recurring').hide();
            $('#group-shipping').hide();
            $('#group-tax').hide();
            $('#group-inventory').hide();
            $('a[href="#tab-inventory"]').parent().addClass("hide"); // specified in _CreateOrUpdate.cshtml
        }
        else if (selectedProductTypeId == '@((int)ProductType.BundledProduct)') {
        	//$('a[href="#tab-inventory"]').parent().addClass("hide"); // specified in _CreateOrUpdate.cshtml
        }
	}
</script>

<div>
	<table class="adminContent">
		@if (Model.Id != 0)
		{
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.Id)
				</td>
				<td class="adminData">
					@Html.TextBoxFor(model => model.Id, new { @readonly = "readonly", @class = "form-control-plaintext" })
					@Html.ValidationMessageFor(model => model.Id)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.ProductUrl)
				</td>
				<td class="adminData">
					<div class="form-control-plaintext">
						<a href="@Model.ProductUrl">@Model.ProductUrl</a>
					</div>
				</td>
			</tr>
		}
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.ProductTypeId)
			</td>
			<td class="adminData">
				@Html.DropDownListFor(model => model.ProductTypeId, ((ProductType)Model.ProductTypeId).ToSelectList())
				@Html.ValidationMessageFor(model => model.ProductTypeId)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.VisibleIndividually)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.VisibleIndividually)
				@Html.ValidationMessageFor(model => model.VisibleIndividually)
			</td>
		</tr>
		@if (Model.Id > 0 && Model.AssociatedToProductId > 0)
		{
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.AssociatedToProductId)
				</td>
				<td class="adminData">
					<div class="form-control-plaintext">
						@Html.ActionLink(Model.AssociatedToProductName, "Edit", "Product", new { id = Model.AssociatedToProductId }, new { })
					</div>
				</td>
			</tr>
		}
		<tr @Html.Raw(Model.AvailableProductTemplates.Count < 2 ? "hidden class='hide hidden-xs-up d-none'" : "")>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.ProductTemplateId)
			</td>
			<td class="adminData">
				@Html.DropDownListFor(model => model.ProductTemplateId, Model.AvailableProductTemplates)
				@Html.ValidationMessageFor(model => model.ProductTemplateId)
			</td>
		</tr>
	</table>

	<p></p>

	@(Html.LocalizedEditor<ProductModel, ProductLocalizedModel>("product-info-localized",
	@<table class="adminContent">
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Locales[item].Name)
			</td>
			<td class="adminData">
				@*IMPORTANT: Do not delete, this hidden element contains the id to assign localized values to the corresponding language *@
				@Html.HiddenFor(model => model.Locales[item].LanguageId)

				@Html.TextBoxFor(model => Model.Locales[item].Name)
				@Html.ValidationMessageFor(model => model.Locales[item].Name)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Locales[item].ShortDescription)
			</td>
			<td class="adminData">
				@Html.TextAreaFor(model => model.Locales[item].ShortDescription)
				@Html.ValidationMessageFor(model => model.Locales[item].ShortDescription)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Locales[item].FullDescription)
			</td>
			<td class="adminData wide">
				@Html.EditorFor(model => model.Locales[item].FullDescription, "Html")
				@Html.ValidationMessageFor(model => model.Locales[item].FullDescription)
			</td>
		</tr>
	</table>
    ,
	@<table class="adminContent">
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Name)
			</td>
			<td class="adminData">
				@Html.TextBoxFor(model => model.Name)
				@Html.ValidationMessageFor(model => model.Name)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.ShortDescription)
			</td>
			<td class="adminData">
				@Html.TextAreaFor(x => x.ShortDescription)
				@Html.ValidationMessageFor(model => model.ShortDescription)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.FullDescription)
			</td>
			<td class="adminData wide">
				@Html.EditorFor(x => x.FullDescription, "Html")
				@Html.ValidationMessageFor(model => model.FullDescription)
			</td>
		</tr>
	</table>
	))

	<table class="adminContent">
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Sku)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.Sku)
				@Html.ValidationMessageFor(model => model.Sku)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.ManufacturerPartNumber)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.ManufacturerPartNumber)
				@Html.ValidationMessageFor(model => model.ManufacturerPartNumber)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Gtin)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.Gtin)
				@Html.ValidationMessageFor(model => model.Gtin)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.CustomsTariffNumber)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.CustomsTariffNumber)
				@Html.ValidationMessageFor(model => model.CustomsTariffNumber)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.CountryOfOriginId)
			</td>
			<td class="adminData">
				@Html.DropDownListFor(model => model.CountryOfOriginId, Model.AvailableCountries, T("Common.Unspecified"))
				@Html.ValidationMessageFor(model => model.CountryOfOriginId)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.AdminComment)
			</td>
			<td class="adminData">
				@Html.TextAreaFor(model => model.AdminComment)
				@Html.ValidationMessageFor(model => model.AdminComment)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.ProductTags)
			</td>
			<td class="adminData">
				@Html.ListBoxFor(model => model.ProductTags, Model.AvailableProductTags, new { multiple = "multiple", data_tags = "true" })
				@Html.ValidationMessageFor(model => model.ProductTags)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.AvailableStartDateTimeUtc)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.AvailableStartDateTimeUtc, new { pickTime = true })
				@Html.ValidationMessageFor(model => model.AvailableStartDateTimeUtc)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.AvailableEndDateTimeUtc)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.AvailableEndDateTimeUtc, new { pickTime = true })
				@Html.ValidationMessageFor(model => model.AvailableEndDateTimeUtc)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.AllowCustomerReviews)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.AllowCustomerReviews)
				@Html.ValidationMessageFor(model => model.AllowCustomerReviews)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.ShowOnHomePage)
			</td>
			<td class="adminData">
				@Html.CheckBoxFor(model => model.ShowOnHomePage, new { data_toggler_for = "#pnlHomePageDisplayOrder" })
				@Html.ValidationMessageFor(model => model.ShowOnHomePage)
			</td>
		</tr>
		<tr id="pnlHomePageDisplayOrder">
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.HomePageDisplayOrder)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.HomePageDisplayOrder)
				@Html.ValidationMessageFor(model => model.HomePageDisplayOrder)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Published)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.Published)
				@Html.ValidationMessageFor(model => model.Published)
			</td>
		</tr>
		@if(Model.CreatedOn.HasValue)
		{
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.CreatedOn)
				</td>
				<td class="adminData">
					<div class="form-control-plaintext">
						@Html.DisplayFor(model => model.CreatedOn)
					</div>
				</td>
			</tr>
		}
		@if(Model.UpdatedOn.HasValue)
		{
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.UpdatedOn)
				</td>
				<td class="adminData">
					<div class="form-control-plaintext">
						@Html.DisplayFor(model => model.UpdatedOn)
					</div>
				</td>
			</tr>
		}
	</table>

	<table class="adminContent" id="group-required-other-products">
		<tr class="adminSeparator">
			<td colspan="2">
				<hr />
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.RequireOtherProducts)
			</td>
			<td class="adminData">
				@Html.CheckBoxFor(model => model.RequireOtherProducts, new { data_toggler_for = "#pnlRequireOtherProducts" })
				@Html.ValidationMessageFor(model => model.RequireOtherProducts)
			</td>
		</tr>
		<tbody id="pnlRequireOtherProducts">
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.RequiredProductIds)
				</td>
				<td class="adminData">
					<div class="input-group">
						@Html.TextBoxFor(model => model.RequiredProductIds, new { @readonly = "readonly" })
						<span class="input-group-append">
							<a class="btn btn-secondary" id="reset-required-productids" title="@T("Admin.Common.Reset")">
								<i class="fa fa-times"></i>
							</a>
						</span>
						<span class="input-group-append">
							@(Html.SmartStore().EntityPicker()
								.For(x => x.RequiredProductIds)
								.DialogTitle(T("Admin.Catalog.Products.Fields.RequireOtherProducts").Text.EncodeJsString('\'', false))
								.Caption(T("Admin.Common.Search").Text.EncodeJsString('\'', false)))
						</span>
					</div>
					@Html.ValidationMessageFor(model => model.RequiredProductIds)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.AutomaticallyAddRequiredProducts)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.AutomaticallyAddRequiredProducts)
					@Html.ValidationMessageFor(model => model.AutomaticallyAddRequiredProducts)
				</td>
			</tr>
		</tbody>
	</table>

	<table class="adminContent" id="group-giftcard">
		<tr class="adminSeparator">
			<td colspan="2">
				<hr />
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.IsGiftCard)
			</td>
			<td class="adminData">
				@Html.CheckBoxFor(model => model.IsGiftCard, new { data_toggler_for = "#pnlGiftCardType" })
				@Html.ValidationMessageFor(model => model.IsGiftCard)
			</td>
		</tr>
		<tr id="pnlGiftCardType">
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.GiftCardTypeId)
			</td>
			<td class="adminData">
				@Html.DropDownListFor(model => model.GiftCardTypeId, ((GiftCardType)Model.GiftCardTypeId).ToSelectList())
				@Html.ValidationMessageFor(model => model.GiftCardTypeId)
			</td>
		</tr>
	</table>

	<table class="adminContent" id="group-recurring">
		<tr class="adminSeparator">
			<td colspan="2">
				<hr />
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.IsRecurring)
			</td>
			<td class="adminData">
				@Html.CheckBoxFor(model => model.IsRecurring, new { data_toggler_for = "#pnlIsRecurring" })
				@Html.ValidationMessageFor(model => model.IsRecurring)
			</td>
		</tr>
		<tbody id="pnlIsRecurring">
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.RecurringCycleLength)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.RecurringCycleLength)
					@Html.ValidationMessageFor(model => model.RecurringCycleLength)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.RecurringCyclePeriodId)
				</td>
				<td class="adminData">
					@Html.DropDownListFor(model => model.RecurringCyclePeriodId, ((RecurringProductCyclePeriod)Model.RecurringCyclePeriodId).ToSelectList())
					@Html.ValidationMessageFor(model => model.RecurringCyclePeriodId)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.RecurringTotalCycles)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.RecurringTotalCycles)
					@Html.ValidationMessageFor(model => model.RecurringTotalCycles)
				</td>
			</tr>
		</tbody>
	</table>

	<table class="adminContent" id="group-shipping">
		<tr class="adminSeparator">
			<td colspan="2">
				<hr />
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.IsShipEnabled)
			</td>
			<td class="adminData">
				@Html.CheckBoxFor(model => model.IsShipEnabled, new { data_toggler_for = "#pnlIsShipEnabled" })
				@Html.ValidationMessageFor(model => model.IsShipEnabled)
			</td>
		</tr>
		<tbody id="pnlIsShipEnabled">
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.DeliveryTimeId)
				</td>
				<td class="adminData">
					@Html.DropDownListFor(model => model.DeliveryTimeId, Model.AvailableDeliveryTimes, T("Common.Unspecified"))
					@Html.ValidationMessageFor(model => model.DeliveryTimeId)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.IsFreeShipping)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.IsFreeShipping)
					@Html.ValidationMessageFor(model => model.IsFreeShipping)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.AdditionalShippingCharge)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.AdditionalShippingCharge, new { postfix = Model.PrimaryStoreCurrencyCode })
					@Html.ValidationMessageFor(model => model.AdditionalShippingCharge)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.QuantityUnitId)
				</td>
				<td class="adminData">
					@Html.DropDownListFor(model => model.QuantityUnitId, Model.AvailableQuantityUnits, T("Common.Unspecified"))
					@Html.ValidationMessageFor(model => model.QuantityUnitId)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.Weight)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.Weight, new { postfix = Model.BaseWeightIn })
					@Html.ValidationMessageFor(model => model.Weight)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.Length)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.Length, new { postfix = Model.BaseDimensionIn })
					@Html.ValidationMessageFor(model => model.Length)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.Width)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.Width, new { postfix = Model.BaseDimensionIn })
					@Html.ValidationMessageFor(model => model.Width)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.Height)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.Height, new { postfix = Model.BaseDimensionIn })
					@Html.ValidationMessageFor(model => model.Height)
				</td>
			</tr>
		</tbody>
	</table>

	<table class="adminContent" id="group-tax">
		<tr class="adminSeparator">
			<td colspan="2">
				<hr />
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.IsTaxExempt)
			</td>
			<td class="adminData">
				@Html.CheckBoxFor(model => model.IsTaxExempt, new { data_toggler_for = "#pnlIsTaxExempt", data_toggler_reverse = "true" })
				@Html.ValidationMessageFor(model => model.IsTaxExempt)
			</td>
		</tr>
		<tbody id="pnlIsTaxExempt">
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.TaxCategoryId)
				</td>
				<td class="adminData">
					@Html.DropDownListFor(model => model.TaxCategoryId, Model.AvailableTaxCategories)
					@Html.ValidationMessageFor(model => model.TaxCategoryId)
				</td>
			</tr>
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.IsEsd)
				</td>
				<td class="adminData">
					@Html.EditorFor(model => model.IsEsd)
					@Html.ValidationMessageFor(model => model.IsEsd)
				</td>
			</tr>
		</tbody>
	</table>
</div>